# Maintainer: David Runge <dave@sleepmap.de>
# Contributor: speps <speps at aur dot archlinux dot org>
# Contributor: Christoph Zeiler <rabyte*gmail>
# Contributor: Tom K <tomk@runbox.com>
# Contributor: Shinlun Hsieh <yngwiexx@yahoo.com.tw>
# Contributor: Philipp Überbacher <murks at lavabit dot com>

pkgname=clthreads
pkgver=2.4.2
pkgrel=5
pkgdesc="C++ wrapper library around the POSIX threads API"
arch=('loong64' 'x86_64')
url="https://kokkinizita.linuxaudio.org/linuxaudio/"
license=('LGPL2.1')
depends=('gcc-libs' 'glibc')
provides=('libclthreads.so')
source=("https://kokkinizita.linuxaudio.org/linuxaudio/downloads/${pkgname}-${pkgver}.tar.bz2")
sha512sums=('a91de7a287c2cb9b2ce17e4c158db79bbaeccb278510d11e6c05fcbe9295c26b4d0231fa97800b265decd1d0886b7425f7b5d4cbcb18758be540356408e72131')

prepare() {
  cd "${pkgname}-${pkgver}/source"
  # remove optimization
  # call ldconfig in local context
  # remove wrongly applied use of PREFIX (line 54,55)
  sed -e '/native/d' \
      -e 's/ldconfig/& -N $(DESTDIR)\/$(LIBDIR)/' \
      -e 's/(PREFIX)\/\$//g' \
      -i Makefile
}

build() {
  cd "${pkgname}-${pkgver}"
  make -C source
}

package(){
  cd "${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}/" PREFIX='/usr' LIBDIR='/usr/lib' -C source install
  install -vDm 644 AUTHORS -t "${pkgdir}/usr/share/doc/${pkgname}"
}
